# Contributor: Hoang Nguyen <folliekazetani@protonmail.com>
# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=ticker
pkgver=4.5.14
pkgrel=5
pkgdesc="Terminal stock watcher and stock position tracker"
url="https://github.com/achannarasappa/ticker"
arch="all"
license="GPL-3.0-or-later"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/achannarasappa/ticker/archive/refs/tags/v$pkgver.tar.gz"
options="!check" # fail presently with current yahoo finance api response

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -v -o bin/ticker \
		-ldflags "-X github.com/achannarasappa/ticker/cmd.Version=v$pkgver"

	./bin/ticker completion bash > ticker.bash
	./bin/ticker completion zsh > ticker.zsh
	./bin/ticker completion fish > ticker.fish
}

check() {
	go test ./...
}

package() {
	install -Dm755 bin/$pkgname "$pkgdir"/usr/bin/$pkgname

	install -Dm644 ticker.bash \
		"$pkgdir"/usr/share/bash-completion/completions/ticker
	install -Dm644 ticker.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/ticker.fish
	install -Dm644 ticker.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_ticker
}

sha512sums="
ba0ed482c950a6056fd662140e00f6f25d9410dbf150232b9c759ee841020935e1cc2ef51b65892dc2e7e85443b01d448defa08adb103b0409863306d24a972e  ticker-4.5.14.tar.gz
"
